<template>
	<div class="loginContent">
		<div class="formBody">
			<el-form :model="formLogin" style="margin-left: 80px;">
				<el-form-item>
					<h2 class="title">文章发布后台管理系统</h2>
				</el-form-item>
				<el-form-item>
					<i class="el-icon-user"></i><el-input type="input" v-model="formLogin.UserName" placeholder="账号"></el-input>
				</el-form-item>
				<el-form-item>
					<i class="el-icon-lock"></i><el-input type="password" v-model="formLogin.Password" placeholder="密码"></el-input>
				</el-form-item>
				<el-form-item id="dl">
					<el-button class="denglu" type="primary" @click="handleLogin">登陆</el-button>
					<el-button class="fanhui" type="primary" @click="handleReturn">返回</el-button>
				</el-form-item>

			</el-form>
		</div>
	</div>
</template>

<script>
import request from './utils/request.js';
export default {
	name: 'Login',
	data() {
		return {
			id: 3,
			pd:null,
			fhz:null,
			formLogin: {
				// //表单对象
				UserName: 'admin',
				Password: 'admin',
				fhz:false,
			},
			apiUrl: process.env.VUE_APP_BASE_ELM_API,
			errorInfo: {
				text: '登陆失败,请重试',
				isShowError: false //显示错误提示
			}
		};
	},
	methods: {
		handleReturn(){
			this.$router.push({ path: '/'});
		},
		handleLogin() {
			let that = this;
			// sessionStorage.setItem('sysuser', JSON.stringify(this.formLogin));
			this.$axios.post(
					'http://localhost:7070/api/Administration/CheckLoginSysUser',
					this.$qs.stringify({userName:that.formLogin.UserName,password:that.formLogin.Password})
			).then(
					function (response) {
						// alert("axios正常运行")
						// alert(that.formLogin.UserName)
						// 	alert("response.data:"+response.data)
						that.fhz = response.data;
						// alert(that.fhz);
						// if (that.pd.equal(true))
						// 	that.fhz = true;
						// else that.fhz = false;
						if(that.fhz)
						{
							// alert("登录成功！");
							// alert(that.fhz);
							that.$message({
								type: 'success',
								message: '登录成功!',
							})
							setTimeout(() => {
								that.$router.push({ path: '/mycenter/zjgl',query:{IUserName:that.formLogin.UserName}});
								// that.$router.push({'path':'/loginH',query:{id:response.data.memid}})
							}, 1000);
						}else alert('用户名或密码错误!');
			})
		},
	}
};
</script>
<style scoped="scoped">
.loginContent {
	background-image: url(assets/images/bg.jpg);
	background-repeat: no-repeat;
	background-size: cover;
	width: 100vw;
	height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
}
.formBody {
	width: 460px;
	height: 296px;
	background: #fff;
	border: 1px solid #eaeaea;
	box-shadow: 0 0 25px #cac6c6;
}
.formBody .title {
	margin-left: 40px;
	color: #505458;
	margin-top: 20px;
}
.el-input{
	padding-left: 5px;
	width:60%;
}
#dl{
	padding-left:30px ;
}
.denglu{
	margin-right: 80px;
}

</style>
